<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>主页</title>
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/plugins/build/css/app.css" media="all">
</head>

<body>
<div class="container" style="padding: 20px 40px 0 0px;">
    <form class="layui-form" action="">
        <input type="hidden" name="userId" value=""/>
        <div class="layui-form-item">
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">再次输入</label>
            <div class="layui-input-block">
                <input type="password" name="repeatPassword" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item custom_layer_bottom_btn">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="save">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script src="/plugins/layui/layui.js"></script>
<script src="/plugins/common.js"></script>
<script>
    //修改地址
    var editUrl = SERVER_URL+"/sysUser/changePassword";

    layui.use(['jquery', 'form'], function() {
        var $ = layui.jquery;
        var form = layui.form;

        //修改密码
        form.on('submit(save)', function(data){
            layer.load(2, {time: 5*1000});
            $.ajax({
                type: 'POST',
                url: editUrl,
                data: data.field,
                success: function (result) {
                    layer.closeAll();
                    if(result.code == 20000){
                        layer.msg('操作成功', {icon: 1,time: 1500}, function(){
                            window.location.reload();
                        })
                    }else{
                        layer.msg(result.msg, {time: 1500});
                    }
                }
            });
            return false;
        });
    });
</script>
</body>

</html>